package com.szrt.socket.ch01.inetaddress.demo01;

import static org.junit.Assert.*;

import java.net.InetAddress;

import org.junit.Test;

public class T1 {
	
	@Test
	public void localhost() throws Exception {
		InetAddress localhost=InetAddress.getLocalHost();
		System.out.println(localhost);
		
		//获取ip地址对应的域名
		System.out.println(localhost.getHostName());
		
		//获得ip地址
		System.out.println(localhost.getHostAddress());
		System.out.println(InetAddress.getByName("MY-THINK"));
	}
	
	@Test
	public void getIpAddress() throws Exception {
		InetAddress ipAddress=InetAddress.getByName("www.baidu.com");
		System.out.println(ipAddress);
		System.out.println(ipAddress.getHostName());
		System.out.println(ipAddress.getHostAddress());
		
		
	}
	
	
	

}
